namespace Ray.Web.Controllers
{
    using System.Collections.Generic;
    using Castle.MonoRail.Framework;
    using Castle.MonoRail.Framework.Helpers;
    using Castle.MonoRail.ActiveRecordSupport;

    using System;
    using Ray.Web.Models;

    [Layout("Admin"), Rescue("generalerror"),ControllerDetails(Area="Admin")]
    public class MasterController : ARSmartDispatcherController
    {
        public void List()
        {
            PropertyBag["items"] = PaginationHelper.CreatePagination(this, PerformSearch(), 5);
        }
        public IList<Ray_Master> PerformSearch()
        {
            return (IList<Ray_Master>)Ray_Master.FindAll();
        }
        public void New()
        {
        }

        [AccessibleThrough(Verb.Post)]
        public void Create([ARDataBind("ray_master", AutoLoadBehavior.OnlyNested)] Ray_Master ray_master)
        {
            try
            {
                ray_master.Create();

                RedirectToAction("List");
            }
            catch (Exception ex)
            {
                Flash["errormessage"] = ex.Message;
                Flash["ray_master"] = ray_master;

                RedirectToAction("New");
            }
        }

        public void Edit()
        {
        }
        public void Update()
        {
        }
        public void ConfirmDelete()
        {
        }
        public void Delete()
        {
        }

    }
}
